import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/home/index'),
      meta: { title: '首页', icon: 'tree' }
    }]
  },

  // 讲师管理
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/list',
    name: '讲师管理',
    meta: { title: '讲师管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '讲师列表',
        component: () => import('@/views/teacher/index'),
        meta: { title: '讲师列表', icon: 'tree' }
      },
      {
        path: 'save',
        name: '添加讲师',
        component: () => import('@/views/teacher/save'),
        meta: { title: '添加讲师', icon: 'tree' }
      },
      {
        path: 'update/:id',
        name: '修改讲师',
        component: () => import('@/views/teacher/save'),
        meta: { title: '修改讲师', icon: 'tree' },
        hidden: true
      }
    ]
  },
  // 科目分类管理
  {
    path: '/subject',
    component: Layout,
    redirect: '/subject/list',
    name: '科目管理',
    meta: { title: '科目管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '科目管理',
        component: () => import('@/views/subject/list'),
        meta: { title: '科目管理', icon: 'tree' }
      },
      {
        path: 'import',
        name: '导入科目',
        component: () => import('@/views/subject/import'),
        meta: { title: '导入科目', icon: 'tree' }
      },
      {
        path: 'update/:id',
        name: '修改讲师',
        component: () => import('@/views/teacher/save'),
        meta: { title: '修改讲师', icon: 'tree' },
        hidden: true
      }
    ]
  },
  // 课程管理
  {
    path: '/course',
    component: Layout,
    redirect: '/course/list',
    name: '课程管理',
    meta: { title: '课程管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '课程列表',
        component: () => import('@/views/course/list'),
        meta: { title: '课程列表', icon: 'tree' }
      },
      {
        path: 'save',
        name: '发布课程',
        component: () => import('@/views/course/save'),
        meta: { title: '发布课程', icon: 'tree' }
      },
      {
        path: 'save/:id',
        name: '发布课程',
        component: () => import('@/views/course/save'),
        meta: { title: '发布课程', icon: 'tree' },
        hidden: true
      },
      // 步骤条
      {
        path: 'info/:id',
        name: '填写课程基本信息',
        component: () => import('@/views/course/info'),
        meta: { title: '填写课程基本信息', icon: 'tree' },
        hidden: true
      },
      {
        path: 'publish/:id',
        name: '提交审核',
        component: () => import('@/views/course/publish'),
        meta: { title: '提交审核', icon: 'tree' },
        hidden: true
      },
    ]
  },

  // 广告管理
  {
    path: '/cms',
    component: Layout,
    redirect: '/cms/list',
    name: '广告管理',
    meta: { title: '广告管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '广告列表',
        component: () => import('@/views/cms/list'),
        meta: { title: '广告列表', icon: 'tree' }
      },
      {
        path: 'type-list',
        name: '广告类型',
        component: () => import('@/views/cms/type-list'),
        meta: { title: '广告类型', icon: 'tree' }
      },
      {
        path: 'from/:id',
        name: '添加广告',
        component: () => import('@/views/cms/from'),
        meta: { title: '添加广告', icon: 'tree' },
        hidden: true
      },
      {
        path: 'from',
        name: '添加广告',
        component: () => import('@/views/cms/from'),
        meta: { title: '添加广告', icon: 'tree' },
      }
    ]
  },

  // 统计
  {
    path: '/statistics',
    component: Layout,
    redirect: '/statistics/chart',
    name: '统计信息',
    meta: { title: '统计信息', icon: 'example' },
    children: [
      {
        path: 'create',
        name: '更新信息',
        component: () => import('@/views/statistics/create'),
        meta: { title: '更新信息', icon: 'tree' }
      },
      {
        path: 'chart',
        name: '统计信息',
        component: () => import('@/views/statistics/chart'),
        meta: { title: '统计信息', icon: 'tree' }
      }

    ]
  },



  {
    path: '/acl',
    component: Layout,
    redirect: '/acl/user/list',
    name: '权限管理',
    meta: { title: '权限管理', icon: 'example' },
    children: [
      {
        path: 'user/list',
        name: '用户管理',
        component: () => import('@/views/acl/user/list'),
        meta: { title: '用户管理', icon: 'tree' }
      },
      {
        path: 'role/list',
        name: '角色管理',
        component: () => import('@/views/acl/role/list'),
        meta: { title: '角色管理', icon: 'tree' }
      },
      {
        path: 'role/form',
        name: '角色添加',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'role/update/:id',
        name: '角色修改',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色修改', icon: 'tree' },
        hidden: true
      },
      {
        path: 'role/distribution/:id',
        name: '角色权限',
        component: () => import('@/views/acl/role/roleForm'),
        meta: { title: '角色权限', icon: 'tree' },
        hidden: true
      },
      {
        path: 'menu/list',
        name: '菜单管理',
        component: () => import('@/views/acl/menu/list'),
        meta: { title: '菜单管理', icon: 'tree' }
      },
      {
        path: 'user/add',
        name: '用户添加',
        component: () => import('@/views/acl/user/form'),
        meta: { title: '用户添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'user/update/:id',
        name: '用户修改',
        component: () => import('@/views/acl/user/form'),
        meta: { title: '用户修改', icon: 'tree' },
        hidden: true
      },
      {
        path: 'user/role/:id',
        name: '用户角色',
        component: () => import('@/views/acl/user/roleForm'),
        meta: { title: '用户角色' },
        hidden: true
      }

    ]
  },

  // 404异常页
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({

  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
